﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace MLY.Validators
{
    //[assembly:TagPrefix("MLY.Validators", "KBMnumericValidator")]
    public class numericValidator : System.Web.UI.WebControls.RegularExpressionValidator
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Display = ValidatorDisplay.Dynamic;
            ValidationExpression = @"^\d+(?:\.\d{0,2})?$";
            ErrorMessage = Dictionary.Translate("validationFailedNumeric");
        }
    }

    //[assembly: TagPrefix("MLY.Validators", "KBMRequiredValidator")]
    public class requiredValidator : System.Web.UI.WebControls.RequiredFieldValidator
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Display = ValidatorDisplay.Dynamic;
            ErrorMessage = Dictionary.Translate("validationFailedRequired");
        }
    }

    //[assembly: TagPrefix("MLY.Validators", "KBMBiggerThenDateValidator")]
    public class BiggerThenEqualDateValidator : System.Web.UI.WebControls.CompareValidator
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Operator = ValidationCompareOperator.GreaterThanEqual;
            this.Type = ValidationDataType.Date;
            ErrorMessage = Dictionary.Translate("validationFailedDateBiggerThenEqual");
            this.Display = ValidatorDisplay.Dynamic;
        }

        public string errorMessage
        {
            get { return ErrorMessage; }
            set { ErrorMessage = value; }
        }
    }

    //[assembly: TagPrefix("MLY.Validators", "KBMPastOnlyDateValidator")]
    public class PastOnlyDateValidator : System.Web.UI.WebControls.CompareValidator
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Operator = ValidationCompareOperator.LessThanEqual;
            this.Type = ValidationDataType.Date;
            this.ValueToCompare = DateTime.Now.ToShortDateString();
            this.Display = ValidatorDisplay.Dynamic;
            ErrorMessage = Dictionary.Translate("validationFailedPastOnly");
        }
    }

    //[assembly: TagPrefix("MLY.Validators", "KBMFutureOnlyDateValidator")]
    public class FutureOnlyDateValidator : System.Web.UI.WebControls.CompareValidator
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Operator = ValidationCompareOperator.GreaterThanEqual;
            this.Type = ValidationDataType.Date;
            this.ValueToCompare = DateTime.Now.ToShortDateString();
            this.Display = ValidatorDisplay.Dynamic;
            ErrorMessage = Dictionary.Translate("validationFailedFutureOnly");
        }
    }

    //[assembly: TagPrefix("MLY.Validators", "KBMDateValidator")]
    public class DateValidator : System.Web.UI.WebControls.CompareValidator
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.Operator = ValidationCompareOperator.DataTypeCheck;
            this.Type = ValidationDataType.Date;
            this.Display = ValidatorDisplay.Dynamic;
            ErrorMessage = Dictionary.Translate("ValidationFailedDates");
        }
    }
   
}
